﻿using Library.Collections.Generic;
using Library.Collections.Specialized;
using Library.Linq;
using Library.Logic.Inference;
using System;
using TRULE = System.Linq.Expressions.Expression<System.Func<System.Linq.IQueryable<Library.Logic.Semantics.IStatement>, System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<Library.Logic.Semantics.IStatement>>>>;

namespace Library.Logic.Semantics
{
    public static class ontology
    {
        //static Uri rdf_type;

        //public static bool IsClass(this Uri thing, Uri @class, ISemanticGraphReadOnly graph)
        //{
        //    return graph.Contains(thing, rdf_type, @class);
        //}
        //public static bool IsClass(this Uri thing, Uri @class, ISemanticGraphReadOnly graph, IReasonerReadOnly<IStatement> reasoner)
        //{
        //    var graph2 = reasoner.Reason(graph);
        //    IContainsStatement contains = graph2 as IContainsStatement;
        //    if(contains != null)
        //    {
        //        return contains.Contains(thing, rdf_type, @class);
        //    }
        //    var statement = graph.CreateStatement(thing, rdf_type, @class);
        //    return graph2.Contains(statement);
        //}
    }

    public interface IStatement : IEdgeFrom<Uri>, IHasValueReadOnly<Uri>, IEdgeTo<object> { }

    public interface IContainsStatement : IContains<IStatement>
    {
        bool Contains(Uri subject, Uri predicate, object @object);
    }

    public interface ISemanticGraphReadOnly : IGraphReadOnly<Uri, IStatement>, IContainsStatement, IContainerBulk<IStatement>
    {
        IStatement CreateStatement(Uri subject, Uri predicate, object @object);
    }

    public interface ISemanticGraph : IGraph<Uri, IStatement>, ISemanticGraphReadOnly, ICollectionBulk<IStatement>
    {
        bool Add(IStatement statement);
        bool Add(Uri subject, Uri predicate, object @object);
        bool Add(Uri subject, Uri predicate, object @object, out IStatement statement);
    }

    public interface ISemanticContext
    {
        IMapCollectionReadOnly<Uri, float> Classes { get; }
        IMapCollectionReadOnly<Uri, float> Individuals { get; }
        IMapCollectionReadOnly<Uri, float> Properties { get; }
    }
}